using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;

namespace IQIGame.Onigao.Logic
{
    public static class LgLevelRegionExtension
    {
        public static void GetBuffHost(this LevelRegion region, LevelBuffHostType hostType, LevelPlayer player, int tagOrMcid, LevelEntity curEntity, List<BaseLevelFunctionHost> hosts)
        {
            switch (hostType)
            {
                case LevelBuffHostType.Player:
                    hosts.Add(player);
                    break;
                case LevelBuffHostType.AllHeroes:
                    for (int i = 0; i < player.heroes.Count; i++)
                    {
                        hosts.Add(player.heroes[i]);
                    }
                    break;
                case LevelBuffHostType.SingleHero: //如果是单个英雄，且为指定，则找队长
                    hosts.Add(player.leaderHero);
                    break;
                case LevelBuffHostType.Entity:
                    List<LevelEntity> entities = ListPool<LevelEntity>.Get();
                    {
                        if (tagOrMcid == -1)
                        {
                            region.GetAllEntities(entities);
                        }
                        else if (tagOrMcid == 0)
                        {
                            entities.Add(curEntity);
                        }
                        else
                        {
                            region.GetEntitiesByTagOrMcid(tagOrMcid, entities);
                        }
                        for (int i = 0; i < entities.Count; i++)
                        {
                            hosts.Add(entities[i]);
                        }
                        ListPool<LevelEntity>.Put(entities);
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
